﻿<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<% String contextPath = request.getContextPath();%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=1">
    <meta http-equiv="cleartype" content="on">
    <title>榆林市社会性别统计平台</title>
    <meta name="keywords" content="榆林市社会性别统计平台"/>
    <meta name="description" content="榆林市社会性别统计平台"/>
    <link rel="stylesheet" type="text/css" href="/resources/css/reset.css"/>
    <link rel="stylesheet" type="text/css" href="/resources/css/login.css"/>
</head>
<body id="ibody" style="display:none">
<div id="wrap">
    <div class="header" id="iHeader" style="padding-top: 22px;">
<%--        <img src="/resources/images/logo-del.png" alt="logo" id="iimage"/>--%>
    </div>
    <div id="content">
        <form class="login loginWarp" id="form1" name="form1" method="post">
            <h3>登录</h3>
            <div class="info">
                <input type="text" id="username" name="username" value="" placeholder="用户名"
                       onblur="alertInput('msg_name');" _msg="msg_name"/>
                <input type="password" id="password" name="password" value="" placeholder="密码"
                       onblur="alertInput('msg_psw');" onkeyup="enter()" _msg="msg_psw"/>
            </div>
            <div class="bottom">
                <input type="button" onclick="submitForm();" value="登录"/>
            </div>
            <p style="color:#656565;padding-left:5px;margin-top:10px;">建议使用火狐、谷歌浏览器</p>
        </form>
    </div>
    <div class="footer" id="iFooter">
        <p>榆林市统计局、榆林市妇女联合会共同承办</p>
        <p>&copy;Copyright2024</p>
    </div>
</div>

<script type="text/javascript" src="/resources/js/jquery-1.12.3.min.js"></script>
<script type="text/javascript" src="/resources/js/jquery.cookie.js"></script>
<script>
    window.onload = setSize;
    var url = "";

    function enter() {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (e && e.keyCode == 13) {
            submitForm();
        }
    }

    function alertInput(target, spanId) {
        target = $("#" + target);
        if (target.val() == null || target.val() == '') {
            $("#" + spanId).show();
            target.focus();
        } else {
            $("#" + spanId).hide();
        }
    }

    function submitForm() {
        if ($("#password").val() == '' || $("#username").val() == '') {
            alert("请检查用户名和密码不要为空 ");
            $("#id").focus();
            return;
        } else {
            $('#form1').submit();
        }
    }

    function clearForm() {
        $('#form1').get(0).reset();
    }

    function setSize() {
        var iBody = document.getElementById('ibody');
        iBody.style.display = "block";
        var iForm1 = document.getElementById("form1");
        var iForm1Css = getComputedStyle(iForm1, null);
        var iImage = document.getElementById("iimage");
        document.getElementById('content').style.height = document.documentElement.offsetHeight - iHeader.offsetHeight - iFooter.offsetHeight + "px"
        if (document.documentElement.offsetHeight > document.documentElement.offsetWidth && (document.documentElement.offsetWidth < parseInt(iForm1Css.width) * 2)) {
            iForm1.style.marginTop = parseInt(document.getElementById('content').style.height) * 0.14 + 'px';
            iImage.style.width = document.documentElement.offsetWidth * 0.8 + "px";
            iImage.style.minHeight = "50px";
        } else {
            iForm1.style.marginTop = parseInt(document.getElementById('content').style.height) * 0.25 + 'px';
        }
    }

    var COOKIE_NAME = 'username';
    var COOKIE_PASSNUMBER = 'password';
    if ($.cookie(COOKIE_NAME)) {
        $("#username").val($.cookie(COOKIE_NAME));
    }
    if ($.cookie(COOKIE_PASSNUMBER)) {
        $("#password").val($.cookie(COOKIE_PASSNUMBER));
    }
    $("#rememberMe").click(function () {
        if (this.checked) {
            $.cookie(COOKIE_NAME, $("#username").val(), {
                path: '/',
                expires: 10,
                domain: 'fuershiye.com',
                secure: true
            });
            $.cookie(COOKIE_PASSNUMBER, $("#password").val(), {
                path: '/',
                expires: 10,
                domain: 'fuershiye.com',
                secure: true
            });
        } else {
            $.cookie(COOKIE_NAME, null, {path: '/'});  //删除cookie
            $.cookie(COOKIE_PASSNUMBER, null, {path: '/'});
        }
    });
</script>
</body>
</html>
